import React from 'react'


import  './SearchInput.less'


import { withRouter } from "react-router";

 class  SearchInput  extends  React.Component {
   constructor(props) {
       super(props)
       this.state={
        values:""
       }
   }

   componentDidMount(props) {
    console.log( this.props)
   }


   getValuesHandler=(e)=>{

    console.log(e.target.value)
       this.setState({
        values:e.target.value
       })
   }

   keyUpHandler=(e)=>{
    
    // console.log(e.keyCode)
    if(e.keyCode===13) {
        // this.state.values
        //search
   
    let url='/search/'+this.state.values
    this.props.history.push(url)

   
      
    }
   }







    render(){
        return(
            <input
                type="text"
                className="search-input"
                value={this.state.values}
                placeholder="请输入搜索内容"
                onKeyUp={ this.keyUpHandler }
                onChange={this.getValuesHandler}
            />
        )
    }
}


export  default  withRouter(SearchInput)